(function(){ "use strict"; //determine if user is accessing from mainland China window.isChina = window.isChina || document.cookie.indexOf('GeoIPCookie=GEOIP_COUNTRY_CODE=CN')>-1; if(window.isChina && document.cookie.indexOf('prcNoticeAccepted=true') < 0){ //cookie not found, china user. //get banner var banner = document.getElementById('prcNoticeBanner'); var acceptButton = document.getElementById('prcNoticeBannerAccept'); //show banner banner.style.display = "block"; acceptButton.onclick = function(event){ //save the acceptance cookie //cookie valid for 30 days/1 month var d = new Date(); d.setTime(d.getTime() + (30*24*60*60*1000)); //figure out the domain var cookieDomain = window.location.hostname; var domainParts = cookieDomain.split('.'); var firstPart = domainParts[0]; if( !isNumeric(firstPart) && (cookieDomain.indexOf("local")<0) && (domainParts.length > 1) ){ cookieDomain = '.' + domainParts.slice(domainParts.length -2).join('.'); } //save the cookie value document.cookie = 'prcNoticeAccepted=true;path=/;expires=' + d.toUTCString() + ';domain='+cookieDomain; banner.style.display = "none"; //stops the click return false; }; } function isNumeric(item){ return !isNaN(parseFloat(item)) && isFinite(item); } })();